package array;

import java.util.HashSet;
import java.util.Set;

public class comArray{
    public static void findCom(int[] array1,int[] array2){
        Set<Integer> set =new HashSet();
        for (int i=0;i< array1.length;i++){
            for (int j =0;j< array2.length;j++){
                if (array1[i]==array2[j]){
                    set.add(array1[i]);
                }
            }
        }
        int[] temp=new int[set.size()];
        int n=0;
        for (int num:set) {
            temp[n]=num;
            n++;
        }
        for (int num:temp) {
            System.out.println(num);
        }
    }

    public static void main(String[] args) {
        int[]arry1={4,9,5};
        int[]array2={9,4,9,8,4};
        findCom(arry1,array2);
    }
}